{include file="header.html"}
<div id="page_main" class="main-right">
  <div id="rightTop">
    <p>{$lang.user}</p>
    <ul class="subnav">
      <li><span>{$lang.manage}</span></li>
      <li><a class="btn1" href="{url route='user/add'}">{$lang.add}</a></li>
    </ul>
  </div>
  <div class="search-form clearfix">
    <form method="get" id="formSearch">
      <input type="hidden" name="r" value="user/index" />
      {$lang.username}
      <input class="queryInput" type="text" name="username" value="{$smarty.get.username|escape}" />
      {$lang.real_name}
      <input class="queryInput" type="text" name="real_name" value="{$smarty.get.real_name|escape}" />
      {$lang.email}
      <input class="queryInput" type="text" name="email" value="{$smarty.get.email|escape}" />
      {$lang.phone_mob}
      <input class="queryInput" type="text" name="phone_mob" value="{$smarty.get.phone_mob|escape}" />
      <input type="submit" class="formbtn" value="{$lang.query}" />
      <!--{if $filtered}--> 
      <a class="formbtn formbtn1" href="{url route='user/index'}">{$lang.cancel_query}</a> 
      <!--{/if}-->
    </form>
  </div>
  <div id="flexigrid"></div>
</div>
<script type="text/javascript">
$(function(){
    $("#flexigrid").flexigrid({
		url: url(['user/index', $("#formSearch").serializeJson()]),
    	colModel : [
    		{ display: '{$lang.operation}', name : 'operation', width : 200, sortable : false, align: 'center', className: 'handle'},
			{ display: '{$lang.username}', name : 'username', width : 100, sortable : true, align: 'center'},
			{ display: '{$lang.real_name}', name : 'real_name', width : 100, sortable : true, align: 'center'},
    		{ display: '{$lang.email}', name : 'email', width : 150, sortable : true, align: 'center'},
			{ display: '{$lang.phone_mob}', name : 'phone_mob', width : 100, sortable : true, align: 'center'},
			{ display: '{$lang.if_admin}', name : 'if_admin', width: 100, sortable : false, align : 'center'},
			{ display: '{$lang.create_time}', name : 'create_time', width: 100, sortable : true, align : 'center'},
			{ display: '{$lang.logins}', name : 'logins', width: 100, sortable : true, align : 'center'},    		
			{ display: '{$lang.last_login}', name : 'last_login', width: 150, sortable : true, align : 'center'},
			{ display: '{$lang.last_ip}', name : 'last_ip', width: 100, sortable : true, align : 'center'} 		
    	],
        buttons : [
            { display: '<i class="fa fa-plus"></i>{$lang.add_data}', name : 'add', bclass : 'add', title : '{$lang.add_data}', onpress : fg_operate },
            { display: '<i class="fa fa-trash"></i>{$lang.batch_del}', name : 'del', bclass : 'del', title : '{$lang.batch_del_for_selected}', onpress : fg_operate },
			{ display: '<i class="fa fa-file-excel-o"></i>{$lang.export_data}', name : 'csv', bclass : 'csv', title : '{$lang.export_data}', onpress : fg_operate }	
        ],
    	title: '{$lang.user_list}'
    });
});
function fg_operate(name, bDiv) {
	if(name == 'add'){
		window.location.href = "{url route='user/add'}";
		return false;
	}
	var itemlist = new Array();
	$('.trSelected',bDiv).each(function(){
		itemlist.push($(this).attr('data-id'));
	});
	if (name == 'del') {
	   if($('.trSelected',bDiv).length == 0){
		   	layer.msg(lang.no_selected_item);
			return false;
	   }
       fg_delete(itemlist,'user');
	}
	if(name == 'csv'){
		if($('.trSelected',bDiv).length == 0){
			layer.confirm(lang.download_all_data,{ icon: 3, title:lang.notice}, function(index){
			fg_csv(itemlist, 'user');
				layer.close(index);
			},function(index){
				layer.close(index);
			});
		}else{
		   fg_csv(itemlist, 'user');
	   }
	}
}
</script> 
{include file="footer.html"} 